<?php
	include "../database.php";
	
        //Za delovanje seje na vseh nivojih
        session_set_cookie_params(0,"/");
        session_start();
        
	$username = $_POST["username"];
	$pass = $_POST["password"];
	
	$query = "SELECT id,username FROM user WHERE username LIKE '$username' AND pass LIKE '$pass';";
	
	$queryResult = executeQuery($query);
	
	$row = mysql_fetch_array($queryResult);
	$count = mysql_num_rows($queryResult);
	
	// Ce dobimo samo en zadetek, potem dodamo uporabnika v sejo
	if($count == 1) {
		$_SESSION['id'] = $row['id'];
		$_SESSION['username'] = $row['username'];
		
		echo json_encode(array('msg' => message(200), 'success' => '1'));
	
	// Za debugiranje
	} else {
		echo json_encode(array('msg' => message(104), 'success' => '0'));
	}
	
?>
